<template>
  <div>
    <form-create
      v-model="fApi"
      :rule="rule"
      :option="option"
      :value="value"
      @update:value="v => $emit('update:value', v)"
    ></form-create>
  </div>
</template>

<script>

import rule from '@/assets/subform-create.json'
import { parseConfig } from '@/utils/utils';
import { mapGetters } from 'vuex';
import { URL_MAP, BACKEND_URL } from '@/config/config';
// parseConfig
// mapGetters
export default {
  data() {
    return {
      //实例对象
      fApi: {},
      //表单数据
      //表单生成规则
      rule: [],
      //组件参数配置
      option: {
        //表单提交事件
        onSubmit: this.onSubmitForm,
        form: {
          labelWidth: '128px'
        }
      },
    };
  },
  props:{
    value:Object
  },
  computed:{
    ...mapGetters([
      'token',
    ])
  },
  methods: {
    onSubmitForm(v) {
      this.$emit("ok", v);
    },
    init() {
      // console.log({ token: this.token, upload_url:  URL_MAP.UPLOAD_URL })
      this.rule = parseConfig(rule, { token: this.token, upload_url: BACKEND_URL + URL_MAP.UPLOAD_URL })
      console.log(rule)
    }
  },
  mounted() {
    this.init();
  }
};
</script>

<style>
</style>